package com.keyue.controller;

import com.keyue.common.constant.ServerResult;
import com.keyue.common.jsr303.OperateGroup;
import com.keyue.domain.vo.AddressInfoQueryVO;
import com.keyue.domain.vo.AddressInfoVO;
import com.keyue.service.AddressInfoService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 地址信息(AddressInfo)表控制层
 *
 * @author makejava
 * @since 2025-07-25 10:44:08
 */
@RestController
@RequestMapping("/keyue/admin/address")
public class AddressInfoController {
    /**
     * 服务对象
     */
    @Resource
    private AddressInfoService addressInfoService;

    /**
     * 分页查询
     *
     * @param addressInfoQueryVO 查询条件
     * @return 查询结果
     */
    @PostMapping("/list_by_page")
    public ServerResult listByPage(@RequestBody @Validated({OperateGroup.List.class}) AddressInfoQueryVO addressInfoQueryVO) {
        return addressInfoService.listByPage(addressInfoQueryVO);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param addressInfoQueryVO 查询条件
     * @return 单条数据
     */
    @PostMapping("/query_by_id")
    public ServerResult queryById(@RequestBody AddressInfoQueryVO addressInfoQueryVO) {
        return addressInfoService.queryById(addressInfoQueryVO);
    }

    /**
     * 新增数据
     *
     * @param addressInfoVO 数据VO
     * @return 新增结果
     */
    @PostMapping("/add")
    public ServerResult add(@RequestBody AddressInfoVO addressInfoVO) {
        return addressInfoService.add(addressInfoVO);
    }

    /**
     * 编辑数据
     *
     * @param addressInfoVO 数据VO
     * @return 编辑结果
     */
    @PostMapping("/edit")
    public ServerResult edit(@RequestBody AddressInfoVO addressInfoVO) {
        return addressInfoService.edit(addressInfoVO);
    }

    /**
     * 删除数据
     *
     * @param addressInfoQueryVO 查询条件
     * @return 删除是否成功
     */
    @PostMapping("/delete_by_id")
    public ServerResult deleteById(@RequestBody AddressInfoQueryVO addressInfoQueryVO) {
        return addressInfoService.deleteById(addressInfoQueryVO);
    }

}

